package com.naiterui.ehp.bs.weixin.security.bean;

import java.util.Collection;
import java.util.Date;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import lombok.Getter;
import lombok.ToString;

@Getter
@ToString
public class JwtUser extends com.naiterui.ehp.bp.support.utils.JwtUser implements UserDetails {

    private final Integer userType;
    private final Long userId;
    private String token;
    private final Boolean enable;
    private final Boolean expire;
    private final Date lastTime;

    public JwtUser(Integer userType, Long userId, Date lastTime) {
        this.userId = userId;
        this.userType = userType;
        this.enable = true;
        this.expire = false;
        this.lastTime = lastTime;
    }

    public JwtUser(Integer userType, Long userId, Boolean enable, Boolean expire, Date lastTime) {
        this.userId = userId;
        this.userType = userType;
        this.enable = enable;
        this.expire = expire;
        this.lastTime = lastTime;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return null;
    }

    @Override
    public String getUsername() {
        return userId + "";
    }

    @Override
    public boolean isAccountNonExpired() {
        return !expire;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return this.enable;
    }

    public void setToken(String token) {
        this.token = token;
    }
}
